package fragmentson;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import com.wq.cycling.R;

import activity.SonActivity;
import fragmentson.backhandle.BackHandledFragment;

/**
 * 编辑价格
 * author：wangqi on 2017/4/26 17:48
 * email：773630555@qq.com
 */
public class ReportLoss_F extends BackHandledFragment {

	private View rootView;
	private EditText et_price;
	private String price;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		rootView = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_reportloss_f, null);
		price = getArguments().getString("price");
		initView();
		return rootView;
	}

	private void initView() {
		// TODO Auto-generated method stub
		((TextView) rootView.findViewById(R.id.tv_title)).setText(R.string.userinfo_nice);
		rootView.findViewById(R.id.tv_next).setOnClickListener(listener);
		et_price = ((EditText) rootView.findViewById(R.id.et_price));
		et_price.setText(price);
	}

	public static ReportLoss_F newInstance(String price, CallBackListener call) {
		ReportLoss_F fragment = new ReportLoss_F();
		Bundle bundle = new Bundle();
		bundle.putString("price",price);
		fragment.setArguments(bundle);
		mcall = call;
		return fragment;
	}

	private View.OnClickListener listener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()){
				case R.id.tv_next:
					mcall.listener(et_price.getText().toString());
					InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
					imm.hideSoftInputFromWindow(et_price.getWindowToken(), 0);
					((SonActivity) getActivity()).backTask();
					break;
				default:
					break;
			}
		}
	};

	@Override
	public boolean onBackPressed() {
		return false;
	}

	public static interface CallBackListener{
		void listener(String item);
	}
	private static CallBackListener mcall;
	
}
